package org.zsk.cs.common;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.zsk.cs.dao.IdentityAuthDao;
import org.zsk.cs.domain.po.IdentityAuth;
import org.zsk.cs.util.UserUtils;

/**
 * <p>
 *     应用工具类
 * </p>
 *
 * @author zsk
 * @version 1.0
 * Created on 2020/5/23
 */
public class AppUtils {

    private final IdentityAuthDao identityAuthDao;

    public AppUtils(IdentityAuthDao identityAuthDao) {
        this.identityAuthDao = identityAuthDao;
    }


    /**
     * @return 当前用户居民身份
     */
    public IdentityAuth getCurResident() {
        return identityAuthDao.selectOne(new LambdaQueryWrapper<IdentityAuth>()
                .eq(IdentityAuth::getUid, UserUtils.getCurrentUser().getId())
                .eq(IdentityAuth::getType,0));
    }

    /**
     * @return 当前用户社区长身份
     */
    public IdentityAuth getDistrictHead() {
        return identityAuthDao.selectOne(new LambdaQueryWrapper<IdentityAuth>()
                .eq(IdentityAuth::getUid, UserUtils.getCurrentUser().getId())
                .eq(IdentityAuth::getType,1));
    }
}
